<?php

namespace App\Http\Controllers\api;

use App\Http\Controllers\Controller;
use App\Models\IntermediaryUser;
use App\Models\WxUser;
use App\Services\RedisFun;
use App\Services\Tencent;
use Illuminate\Http\Request;

class TestController extends Controller
{
    public static function getkey(){
        $config=[
          'host'=>'127.0.0.1',
          'port'=>'6379',
          'auth'=>''
        ];
        $attr=[];
        $redis=new RedisFun($config,$attr);
        $value=$redis->get('name');
        var_dump($value);
    }

    public function getUserSign(Request $request)
    {
        $key = 'd9a0ba700e80039ec243fb34f6dbc36108f6b56ac7decf0bd3367351f67ae5af';
        $sdkappid = '1400598394';
        $user_id = 'Broker_'.$request->get('id');
        $res = (new Tencent($sdkappid,$key))->genUserSig($user_id);
        $userInfo = IntermediaryUser::where('id',$request->get('id'))->first();
        return ['code'=>10001,'msg'=>'请求成功','data'=>['userSig'=>$res,'user_id'=>$user_id,'userInfo'=>$userInfo]];
    }

    public static function registerUser($user_id)
    {
        $key = 'd9a0ba700e80039ec243fb34f6dbc36108f6b56ac7decf0bd3367351f67ae5af';
        $sdkappid = '1400598394';
        $res = (new Tencent($sdkappid,$key))->genUserSig($user_id);
        return $res;
    }
}
